package com.zhonghui.kf.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.zhonghui.common.core.domain.entity.SysUser;
import com.zhonghui.kf.domain.vo.ProcurementChatShistoryVo;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zhonghui.common.annotation.Log;
import com.zhonghui.common.core.controller.BaseController;
import com.zhonghui.common.core.domain.AjaxResult;
import com.zhonghui.common.enums.BusinessType;
import com.zhonghui.kf.domain.ProcurementChatShistory;
import com.zhonghui.kf.service.IProcurementChatShistoryService;
import com.zhonghui.common.utils.poi.ExcelUtil;
import com.zhonghui.common.core.page.TableDataInfo;

/**
 * 客服聊天记录Controller
 * 
 * @author zhonghui
 * @date 2023-11-29
 */
@RestController
@RequestMapping("/chat/historys")
public class ProcurementChatShistoryController extends BaseController
{
    @Autowired
    private IProcurementChatShistoryService procurementChatShistoryService;


    @GetMapping("/userList/{ids}")
    public AjaxResult getUserList(@PathVariable Long[] ids)
    {
        List<ProcurementChatShistoryVo> list = procurementChatShistoryService.getUserList(ids);
        return  success(list);
    }

    /**
     * 查询客服聊天记录列表
     */
    @GetMapping("/list")
    public AjaxResult list(ProcurementChatShistory procurementChatShistory)
    {
        List<ProcurementChatShistory> list = procurementChatShistoryService.selectProcurementChatShistoryList(procurementChatShistory);
        return success(list);
    }

    /**
     * 导出客服聊天记录列表
     */
    @Log(title = "客服聊天记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ProcurementChatShistory procurementChatShistory)
    {
        List<ProcurementChatShistory> list = procurementChatShistoryService.selectProcurementChatShistoryList(procurementChatShistory);
        ExcelUtil<ProcurementChatShistory> util = new ExcelUtil<ProcurementChatShistory>(ProcurementChatShistory.class);
        util.exportExcel(response, list, "客服聊天记录数据");
    }

    /**
     * 获取客服聊天记录详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(procurementChatShistoryService.selectProcurementChatShistoryById(id));
    }

    /**
     * 新增客服聊天记录
     */
    @Log(title = "客服聊天记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ProcurementChatShistory procurementChatShistory)
    {
        return toAjax(procurementChatShistoryService.insertProcurementChatShistory(procurementChatShistory));
    }

    /**
     * 修改客服聊天记录
     */
    @Log(title = "客服聊天记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ProcurementChatShistory procurementChatShistory)
    {
        return toAjax(procurementChatShistoryService.updateProcurementChatShistory(procurementChatShistory));
    }

    /**
     * 删除客服聊天记录
     */
    @Log(title = "客服聊天记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(procurementChatShistoryService.deleteProcurementChatShistoryByIds(ids));
    }
}
